package com.spring.sso.config.security.filter.oauth2;

import com.spring.sso.config.common.AuthenticationConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer;
import org.springframework.security.oauth2.provider.client.ClientCredentialsTokenEndpointFilter;
import org.springframework.security.oauth2.provider.client.JdbcClientDetailsService;
import org.springframework.security.oauth2.provider.endpoint.AuthorizationEndpoint;

import javax.annotation.PostConstruct;

/**
 * 自定义AuthorizationEndpoint配置，此处自定义配置授权页面
 * @author : pangfuzhong
 * @description
 * @date : 2021/10/12 11:23
 */
@Configuration
public class EndpointConfiguration {

    @Autowired
    private AuthorizationEndpoint authorizationEndpoint;

    @Autowired
    private AuthenticationConfig authenticationConfig;

    @PostConstruct
    public void init() {
        // 当需要自定义授权页面供用户选择权限以及错误页面时，可按照如下参数进行配置指定的授权页面和错误页面，如果没有需要注释掉该配置使用spring-security-oauth2默认的授权页
        //this.authorizationEndpoint.setUserApprovalPage(this.authenticationConfig.getOauthUserApprovalPage());
        //this.authorizationEndpoint.setErrorPage(this.authenticationConfig.getOauthErrorPage());
    }
}
